<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="办理单编码" prop="srvFbcode">
        <el-input
          v-model="queryParams.srvFbcode"
          placeholder="请输入办理单编码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="承办单位编码" prop="extFmcode">
        <el-input
          v-model="queryParams.extFmcode"
          placeholder="请输入承办单位编码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="承办人" prop="srvTfdealer">
        <el-input
          v-model="queryParams.srvTfdealer"
          placeholder="请输入承办人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="承办时间" prop="srvTfdealtime">
        <el-date-picker clearable size="small"
          v-model="queryParams.srvTfdealtime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择承办时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="审签人" prop="srvTfauditpeople">
        <el-input
          v-model="queryParams.srvTfauditpeople"
          placeholder="请输入审签人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审签时间" prop="srvTfaudittime">
        <el-date-picker clearable size="small"
          v-model="queryParams.srvTfaudittime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择审签时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="领导" prop="srvTfleader">
        <el-input
          v-model="queryParams.srvTfleader"
          placeholder="请输入领导"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="批示时间" prop="srvTfleadtime">
        <el-date-picker clearable size="small"
          v-model="queryParams.srvTfleadtime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择批示时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="创建人" prop="srvTfoper">
        <el-input
          v-model="queryParams.srvTfoper"
          placeholder="请输入创建人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" prop="srvTfopertime">
        <el-date-picker clearable size="small"
          v-model="queryParams.srvTfopertime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="最后修改人" prop="srvTflmoper">
        <el-input
          v-model="queryParams.srvTflmoper"
          placeholder="请输入最后修改人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最后修改时间" prop="srvTflmtime">
        <el-date-picker clearable size="small"
          v-model="queryParams.srvTflmtime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择最后修改时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="审核状态" prop="srvTfcheck">
        <el-input
          v-model="queryParams.srvTfcheck"
          placeholder="请输入审核状态"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审核人" prop="srvTfcheckoper">
        <el-input
          v-model="queryParams.srvTfcheckoper"
          placeholder="请输入审核人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审核时间" prop="srvTfchecktime">
        <el-date-picker clearable size="small"
          v-model="queryParams.srvTfchecktime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择审核时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="回复次数" prop="srvTftimes">
        <el-input
          v-model="queryParams.srvTftimes"
          placeholder="请输入回复次数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系电话" prop="srvTflinktel">
        <el-input
          v-model="queryParams.srvTflinktel"
          placeholder="请输入联系电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号码" prop="srvTfphone">
        <el-input
          v-model="queryParams.srvTfphone"
          placeholder="请输入手机号码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="回复情况" prop="srvTfhuifu">
        <el-input
          v-model="queryParams.srvTfhuifu"
          placeholder="请输入回复情况"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="满意度" prop="srvTfmanyi">
        <el-input
          v-model="queryParams.srvTfmanyi"
          placeholder="请输入满意度"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="回复时间" prop="srvTfretime">
        <el-date-picker clearable size="small"
          v-model="queryParams.srvTfretime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择回复时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="回复方式" prop="srvTfreway">
        <el-input
          v-model="queryParams.srvTfreway"
          placeholder="请输入回复方式"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否提交办结" prop="srvTfistijiao">
        <el-input
          v-model="queryParams.srvTfistijiao"
          placeholder="请输入是否提交办结"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="首日联系市民" prop="srvTffirstcontaction">
        <el-input
          v-model="queryParams.srvTffirstcontaction"
          placeholder="请输入首日联系市民"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:tickingform:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:tickingform:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:tickingform:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:tickingform:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="tickingformList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="srvTfcode" />
      <el-table-column label="办理单编码" align="center" prop="srvFbcode" />
      <el-table-column label="承办单位编码" align="center" prop="extFmcode" />
      <el-table-column label="承办人" align="center" prop="srvTfdealer" />
      <el-table-column label="承办时间" align="center" prop="srvTfdealtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.srvTfdealtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审签人" align="center" prop="srvTfauditpeople" />
      <el-table-column label="审签时间" align="center" prop="srvTfaudittime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.srvTfaudittime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="领导" align="center" prop="srvTfleader" />
      <el-table-column label="领导意见" align="center" prop="srvTfleadidea" />
      <el-table-column label="批示时间" align="center" prop="srvTfleadtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.srvTfleadtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="回复内容" align="center" prop="srvTfanswer" />
      <el-table-column label="备注" align="center" prop="srvTfdes" />
      <el-table-column label="创建人" align="center" prop="srvTfoper" />
      <el-table-column label="创建时间" align="center" prop="srvTfopertime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.srvTfopertime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最后修改人" align="center" prop="srvTflmoper" />
      <el-table-column label="最后修改时间" align="center" prop="srvTflmtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.srvTflmtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审核状态" align="center" prop="srvTfcheck" />
      <el-table-column label="审核人" align="center" prop="srvTfcheckoper" />
      <el-table-column label="审核时间" align="center" prop="srvTfchecktime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.srvTfchecktime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="回复次数" align="center" prop="srvTftimes" />
      <el-table-column label="联系电话" align="center" prop="srvTflinktel" />
      <el-table-column label="手机号码" align="center" prop="srvTfphone" />
      <el-table-column label="回复情况" align="center" prop="srvTfhuifu" />
      <el-table-column label="满意度" align="center" prop="srvTfmanyi" />
      <el-table-column label="回复时间" align="center" prop="srvTfretime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.srvTfretime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="回复方式" align="center" prop="srvTfreway" />
      <el-table-column label="不回复原因" align="center" prop="srvTfnoyuanyin" />
      <el-table-column label="是否提交办结" align="center" prop="srvTfistijiao" />
      <el-table-column label="网上答复意见" align="center" prop="srvTfonlineadvice" />
      <el-table-column label="不满意原因" align="center" prop="answerdegreereason" />
      <el-table-column label="首日联系市民" align="center" prop="srvTffirstcontaction" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:tickingform:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:tickingform:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改反馈单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="办理单编码" prop="srvFbcode">
          <el-input v-model="form.srvFbcode" placeholder="请输入办理单编码" />
        </el-form-item>
        <el-form-item label="承办单位编码" prop="extFmcode">
          <el-input v-model="form.extFmcode" placeholder="请输入承办单位编码" />
        </el-form-item>
        <el-form-item label="承办人" prop="srvTfdealer">
          <el-input v-model="form.srvTfdealer" placeholder="请输入承办人" />
        </el-form-item>
        <el-form-item label="承办时间" prop="srvTfdealtime">
          <el-date-picker clearable size="small"
            v-model="form.srvTfdealtime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择承办时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="审签人" prop="srvTfauditpeople">
          <el-input v-model="form.srvTfauditpeople" placeholder="请输入审签人" />
        </el-form-item>
        <el-form-item label="审签时间" prop="srvTfaudittime">
          <el-date-picker clearable size="small"
            v-model="form.srvTfaudittime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择审签时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="领导" prop="srvTfleader">
          <el-input v-model="form.srvTfleader" placeholder="请输入领导" />
        </el-form-item>
        <el-form-item label="领导意见" prop="srvTfleadidea">
          <el-input v-model="form.srvTfleadidea" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="批示时间" prop="srvTfleadtime">
          <el-date-picker clearable size="small"
            v-model="form.srvTfleadtime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择批示时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="回复内容" prop="srvTfanswer">
          <el-input v-model="form.srvTfanswer" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注" prop="srvTfdes">
          <el-input v-model="form.srvTfdes" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="创建人" prop="srvTfoper">
          <el-input v-model="form.srvTfoper" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="创建时间" prop="srvTfopertime">
          <el-date-picker clearable size="small"
            v-model="form.srvTfopertime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="最后修改人" prop="srvTflmoper">
          <el-input v-model="form.srvTflmoper" placeholder="请输入最后修改人" />
        </el-form-item>
        <el-form-item label="最后修改时间" prop="srvTflmtime">
          <el-date-picker clearable size="small"
            v-model="form.srvTflmtime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择最后修改时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="审核状态" prop="srvTfcheck">
          <el-input v-model="form.srvTfcheck" placeholder="请输入审核状态" />
        </el-form-item>
        <el-form-item label="审核人" prop="srvTfcheckoper">
          <el-input v-model="form.srvTfcheckoper" placeholder="请输入审核人" />
        </el-form-item>
        <el-form-item label="审核时间" prop="srvTfchecktime">
          <el-date-picker clearable size="small"
            v-model="form.srvTfchecktime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择审核时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="回复次数" prop="srvTftimes">
          <el-input v-model="form.srvTftimes" placeholder="请输入回复次数" />
        </el-form-item>
        <el-form-item label="联系电话" prop="srvTflinktel">
          <el-input v-model="form.srvTflinktel" placeholder="请输入联系电话" />
        </el-form-item>
        <el-form-item label="手机号码" prop="srvTfphone">
          <el-input v-model="form.srvTfphone" placeholder="请输入手机号码" />
        </el-form-item>
        <el-form-item label="回复情况" prop="srvTfhuifu">
          <el-input v-model="form.srvTfhuifu" placeholder="请输入回复情况" />
        </el-form-item>
        <el-form-item label="满意度" prop="srvTfmanyi">
          <el-input v-model="form.srvTfmanyi" placeholder="请输入满意度" />
        </el-form-item>
        <el-form-item label="回复时间" prop="srvTfretime">
          <el-date-picker clearable size="small"
            v-model="form.srvTfretime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择回复时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="回复方式" prop="srvTfreway">
          <el-input v-model="form.srvTfreway" placeholder="请输入回复方式" />
        </el-form-item>
        <el-form-item label="不回复原因" prop="srvTfnoyuanyin">
          <el-input v-model="form.srvTfnoyuanyin" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="是否提交办结" prop="srvTfistijiao">
          <el-input v-model="form.srvTfistijiao" placeholder="请输入是否提交办结" />
        </el-form-item>
        <el-form-item label="网上答复意见" prop="srvTfonlineadvice">
          <el-input v-model="form.srvTfonlineadvice" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="不满意原因" prop="answerdegreereason">
          <el-input v-model="form.answerdegreereason" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="首日联系市民" prop="srvTffirstcontaction">
          <el-input v-model="form.srvTffirstcontaction" placeholder="请输入首日联系市民" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listTickingform, getTickingform, delTickingform, addTickingform, updateTickingform } from "@/api/system/tickingform";

export default {
  name: "Tickingform",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 反馈单表格数据
      tickingformList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        srvFbcode: null,
        extFmcode: null,
        srvTfdealer: null,
        srvTfdealtime: null,
        srvTfauditpeople: null,
        srvTfaudittime: null,
        srvTfleader: null,
        srvTfleadidea: null,
        srvTfleadtime: null,
        srvTfanswer: null,
        srvTfdes: null,
        srvTfoper: null,
        srvTfopertime: null,
        srvTflmoper: null,
        srvTflmtime: null,
        srvTfcheck: null,
        srvTfcheckoper: null,
        srvTfchecktime: null,
        srvTftimes: null,
        srvTflinktel: null,
        srvTfphone: null,
        srvTfhuifu: null,
        srvTfmanyi: null,
        srvTfretime: null,
        srvTfreway: null,
        srvTfnoyuanyin: null,
        srvTfistijiao: null,
        srvTfonlineadvice: null,
        answerdegreereason: null,
        srvTffirstcontaction: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询反馈单列表 */
    getList() {
      this.loading = true;
      listTickingform(this.queryParams).then(response => {
        this.tickingformList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        srvTfcode: null,
        srvFbcode: null,
        extFmcode: null,
        srvTfdealer: null,
        srvTfdealtime: null,
        srvTfauditpeople: null,
        srvTfaudittime: null,
        srvTfleader: null,
        srvTfleadidea: null,
        srvTfleadtime: null,
        srvTfanswer: null,
        srvTfdes: null,
        srvTfoper: null,
        srvTfopertime: null,
        srvTflmoper: null,
        srvTflmtime: null,
        srvTfcheck: null,
        srvTfcheckoper: null,
        srvTfchecktime: null,
        srvTftimes: null,
        srvTflinktel: null,
        srvTfphone: null,
        srvTfhuifu: null,
        srvTfmanyi: null,
        srvTfretime: null,
        srvTfreway: null,
        srvTfnoyuanyin: null,
        srvTfistijiao: null,
        srvTfonlineadvice: null,
        answerdegreereason: null,
        srvTffirstcontaction: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.srvTfcode)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加反馈单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const srvTfcode = row.srvTfcode || this.ids
      getTickingform(srvTfcode).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改反馈单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.srvTfcode != null) {
            updateTickingform(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTickingform(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const srvTfcodes = row.srvTfcode || this.ids;
      this.$confirm('是否确认删除反馈单编号为"' + srvTfcodes + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delTickingform(srvTfcodes);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/tickingform/export', {
        ...this.queryParams
      }, `system_tickingform.xlsx`)
    }
  }
};
</script>